<template>
	<view class="cu-modal " :class="showMyPoster?'show':''">
		<view class="cu-dialog my-prize-dialog poster">			
			<view id="poster_content" class="content">
				<view class="close" @tap="hide">
					<uni-icons type="closeempty" size="35" color="#fff"></uni-icons>
				</view>
				<image :src="posterUrl" style="height: 60vh;" mode="heightFix"></image>
				<view class="qrcode-content">
					<view style="width: 175px;height:175px;background-color: #fff;padding: 10rpx;">
						<canvas id="qrcode" canvas-id="qrcode" style="width: 175px;height:175px;" />
					</view>
					<view class="tips">长按识别二维码</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import UQRCode from 'uqrcodejs';
	import html2canvas from 'html2canvas'
	// #ifdef H5
	import { hb_class } from '../../utils/index.js'
	// #endif
	export default {
		data(){
			return {
				showMyPoster: false,
				myPosterlist: [],
				posterUrl: ''
			}
		},
		mounted() {
			this.getQr()
		},
		methods: {
			getQr(){
				const qr = new UQRCode();
				// qr.data = res.msg.url;
				qr.data = 'http://localhost:5173/'
				qr.size = 175;
				qr.make();
				const ctx = uni.createCanvasContext('qrcode', this);
				qr.canvasContext = ctx;
				qr.drawCanvas();
			},
			// 获取海报链接地址
			getLink(openid){
				this.$comm.http('/api/activelove/share_url', {openid},"POST").then(res=>{
					if(res.code === 404){
						this.$emit('onInit')
						return
					}
					
				})
			},
			open(openid){
				this.showMyPoster = true
				this.getLink(openid)
			},
			hide(){
				this.showMyPoster = false
			}
		}
	}
</script>

<style lang="scss" scoped>
	.poster{
		background-color: transparent;
		.content{
			display: flex;
			flex-direction: column;
			align-items: center;
			position: relative;
			.qrcode-content{
				background-color: #bc0c1b;
				width: 150rpx;
				height: 182rpx;
				position: absolute;
				bottom: 180rpx;
				right: -250rpx;
				.tips{
					font-size: 20rpx;
					color: #fff;
				}
			}
		}
	}
</style>